package com.santiao.fuel.ui.adapter;


import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.santiao.fuel.R;
import com.santiao.fuel.bean.InnerBean;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Mr.xie
 * @Date 2025/1/3
 */
class RVGouNeiGasPriceVH extends RecyclerView.ViewHolder{

    public RVGouNeiGasPriceVH(@NonNull View itemView) {
        super(itemView);
    }
}
public class RvGouNeiGasPriceAdaper extends RecyclerView.Adapter<RVGouNeiGasPriceVH>{

    private Context _context;

    private List<InnerBean> datas = new ArrayList<>();

    public RvGouNeiGasPriceAdaper(Context _context, List<InnerBean> datas) {
        this._context = _context;
        this.datas = datas;
    }

    @NonNull
    @Override
    public RVGouNeiGasPriceVH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new RVGouNeiGasPriceVH(LayoutInflater.from(_context).inflate(R.layout.table_inner_2 , parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull RVGouNeiGasPriceVH holder, int position) {
        if (position % 2 ==0 ){
            holder.itemView.setBackgroundColor(Color.parseColor("#fefaf4"));
        }else {
            holder.itemView.setBackgroundColor(Color.parseColor("#ffffff"));
        }
        TextView row_name = holder.itemView.findViewById(R.id.row_name);
        TextView row_unit = holder.itemView.findViewById(R.id.row_unit);
        TextView qh_rate = holder.itemView.findViewById(R.id.qh_rate);
        InnerBean innerBean = datas.get(position);
        row_name.setText(innerBean.getRecvie_statation());
        row_unit.setText(innerBean.getGuapai());
        qh_rate.setText(innerBean.getQh_rate());
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }
}
